Skip to content

refactor(go)!: move vitaminc's Go frame codec and value types into the module - #2003

Open
coderdan wants to merge 26 commits into
nextfrom
refactor/go-frame-codec-in-module
Open

coderdan wants to merge 26 commits into
nextfrom
refactor/go-frame-codec-in-module

Conversation

@coderdan

@coderdan coderdan commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The Go SDK no longer imports vitaminc's Go packages vcffi and vcvalue. Their code now lives in the module as languages/golang/internal/frame. encrypt's value types are types of their own instead of aliases of vitaminc's. The go.mod pin on an untagged vitaminc commit is gone, so the release script's rule refusing a final version while that pin exists is removed too. This is the last stage of moving the AEAD code into this repository, and it unblocks a final Go release.

Refs #1253 (everything but its item 5, the differential fuzzers, which is now #2004). Refs #1831.

Changes

  1. Copied, then reshaped. vcffi and vcvalue are copied byte for byte from the Go module cache, at the version the SDK pinned: vitaminc f1fc9ae74, v0.0.0-20261119095843-f1fc9ae74882. Their MIT licence comes with them. The later commits:

    • merge the two packages into one internal package, internal/frame;
    • point its tests at this repository's corpora;
    • drop what only vitaminc's vcencrypt needed.

    FixedType is gone. The typed null of a nil pointer is built from the tag table, so its bytes are unchanged, and the known-answer tests still pin them. record.Kind is the one list of type names on the Go side.

  2. Public types (breaking).

    • Date, Decimal, Int128 and Uint128 are types of their own, with the same fields.
    • New: UUID, ParseUUID and UUID.String.
    • New: Encryptable (EncryptValue(enc Encoder) error), and Encoder with one method per scalar.
    • Removed: Date.DaysFromCE and Decimal.Normalized.
    • The parse functions and ErrNonFiniteDecimal keep their names. The error still matches with errors.Is, but its message now starts "frame: ".

    The codec cannot import encrypt, which imports it. So encrypt's init registers each public type with the codec. The codec then writes a public value as its own type, and decodes its own type back as the public one. Nothing in generated code converts.

  3. go.mod. The root module, encrypt/encrypttest and encrypt/example drop the vcffi and vcvalue requirements. go mod tidy changed nothing else.

  4. Release script. scripts/go-release-version.mjs drops the rule that refused a final version while go.mod pinned a vitaminc pseudo-version, and its tests. A new test checks that a final version from main is accepted. The rule is removed rather than kept, because no dependency remains that could carry such a pin. AGENTS.md is updated.

  5. Tests and fuzzing. These moved with the code:

    • the value conformance corpus (conformance/vitaminc-aead/value-conformance.json), every section;
    • the storage corpus (packages/recipher-frame/testdata/storage-v1.json), 125 subtests;
    • the hostile-input tests;
    • three fuzz targets with their seed corpora, which are added to the nightly go-fuzz-campaign in fuzz.yml.

    New tests cover the registration and every Encoder method.

  6. Docs. languages/golang/CHANGELOG.md has a Breaking entry. Also updated: AGENTS.md, the READMEs, STORAGE.md, the conformance docs, and the plan's stage 3 "Done" list.

Verification

  • With all five guests built:
    • go build, go vet, gofmt -l (empty) and go test pass in every module;
    • STACK_CONFORMANCE_REQUIRED=1 go test ./... passes (encrypt takes about seven minutes);
    • go generate ./... leaves no drift;
    • GOARCH=386 go vet passes;
    • golangci-lint reports 0 issues;
    • each fuzz target ran for 15 seconds with no failure.
  • After merging next (which added refactor(eql-bindings)!: name a target's plaintext with ValueKind; keep the Go guest's frame parse in one helper #1995): go build, go vet and the internal tests pass again.
  • The release-script and crates CI script tests pass (32 and 56 tests).
  • Not run: the Windows and macOS jobs, live tests, and the guest import-surface checks. Rust is unchanged.

Review notes

Open questions:

  1. Where the public types live. They are in encrypt, as Go SDK: bring the frame codec and value types in from vitaminc, so the Go host and Rust guest codecs are pinned together #1253 proposes, which needs the registration at init. The other option is a small public value package.
  2. Encoder. It covers scalars only. Should it also cover containers or a passthrough?
  3. Removed methods. Is dropping Date.DaysFromCE and Decimal.Normalized acceptable?
  4. encrypt.UUID is new public API.
  5. Exported methods that take internal types. encrypt.Cipher's QueryTerm, Verify, TargetLimit, Contexts, Seal, Open and JSONOpen take a *record.Plan, and JSONOpen also takes a frame.Object. A program cannot import either. They are documented as being for generated code, and the *record.Plan part predates this PR. Should they move behind gensupport?
  6. Nil pointers. A nil pointer to a user's Encryptable is now refused on a field with no declared type, so the stored length cannot show a null. On a typed field, the engine pads a sealed null to the declared type.

Also:

… module

The Go SDK encodes every value it hands the guest with vitaminc's Go
packages vcffi and vcvalue. They were pinned in go.mod at an untagged
commit, so the Go half of the frame codec moved separately from the Rust
half (recipher-frame, now in this repository), and a final release of the
module was refused while the pin stood.

This commit copies both packages in, unchanged, so the move can be
compared with the source file by file:

  vcffi   -> languages/golang/internal/frame
  vcvalue -> languages/golang/internal/value

Source: github.com/cipherstash/vitaminc bindings/go/vcffi and
bindings/go/vcvalue at commit f1fc9ae74882 (pseudo-version
v0.0.0-20261119095843-f1fc9ae74882), the version go.mod pins, taken from
the Go module cache. Each module's go.mod is left out, so the two
directories are packages of this module. The files carry no licence
headers; each package's MIT LICENSE file comes with it.

Nothing imports the copies yet, and their package clauses and corpus
paths are still vitaminc's. The next commits make them the module's own.
vcffi and vcvalue were two modules because vitaminc had two consumers of
the value model. Here there is one, so the value model joins the codec in
languages/golang/internal/frame: the value types, Object, Field and Plain
sit beside the code that reads and writes them.

- Package clauses are frame (and frame_test), and the codec names the
  value types without a qualifier.
- vcvalue's scalars.go is values.go here, beside the codec's scalars.go.
- The tests read the corpora from this repository: the value corpus at
  conformance/vitaminc-aead/value-conformance.json and the storage corpus
  at packages/recipher-frame/testdata/storage-v1.json. Both pass row by
  row, so the Go codec still writes the bytes the Rust crate pins.
- Error text starts "frame: ".
- The package doc says what the package is here. The READMEs, which
  described vitaminc's module layout, are gone, and so are comments that
  named vitaminc's issues, its ADR numbers and its other bindings.

No code changes behaviour. The API is still vitaminc's, including the
parts only vitaminc's own binding used; the next commit removes those.
The copied codec carried parts that only vitaminc's demonstration binding
used. Nothing in this module uses them:

- The sealed leaf family (Sealed, SealedEmptySeq, SealedEmptyMap) and
  their LeafSet, VCValueLeaves. The SDK has its own leaf types in package
  encrypt. The codec's tests keep a leaf set of their own, in
  leaves_test.go, so every ciphertext test still runs.
- Plain's driver.Valuer, which bound a passthrough straight into a
  database. The SDK keeps passthrough values on the host.
- TypedNull, a marker type for writing a typed null by naming its type,
  and FixedWidth, which let an Encryptable name the width of its null.
  The guest pads a null to the width of the field's declared type, so a
  type named by the host changes nothing that is stored.

FixedType, the enum those two named types by, was one more copy of the
list of value types. It is gone, not replaced: a nil pointer to a
fixed-width type still writes the same typed null, which is now built
from the tag a value of the type is written with. The tag table is the
codec's only list of types, and record.Kind stays the module's only list
of type names. The known-answer tests pin every typed null's bytes, now
through a nil pointer to each type, and the bytes have not changed.

The codec converts between integer widths on purpose, so the linter's
integer conversion check (gosec G115) is turned off for internal/frame
only.
Every package that imported vitaminc's vcffi or vcvalue now imports
internal/frame: auth, encrypt, encrypt/gensupport, internal/guest and
internal/record, and their tests. The calls are the same; only the
qualifier changes.

encrypt's value types are still aliases at this commit, now of the types
in internal/frame. The next commit gives them types of their own.

The check in encrypt's tests that a vitaminc Sealed leaf is refused as a
Stack Encrypt leaf goes, because the codec no longer has that type. A few
test locals named frame are renamed so they do not hide the package, and
comments that named vcffi now say "the codec".

The whole module's tests pass against the built guests.
…of their own

encrypt.Date, Decimal, Int128 and Uint128 were aliases of vitaminc's Go
value types, so vitaminc's API was part of the SDK's, and a change there
was a breaking change here, made in another repository. Each is now a type
declared in encrypt, with the fields it had and the methods a caller uses
(Validate, String, IsZero). encrypt.UUID is new: the UUID kind took a
vcvalue.UUID, which a caller could only name through vitaminc.

The codec cannot import encrypt, which imports it. So each public type is
a type over the same underlying type as the codec's value type, and
encrypt's init tells the codec about it with frame.Publish. The codec then
reads the public type as its own and decodes its own as the public type:
the same bytes, with no conversion in the SDK or in generated code. A
program that links encrypt can only hold a public value after that init
has run. frame.PublishEncryptable does the same for encrypt.Encryptable,
whose method takes encrypt.Encoder, a wrapper over the codec's Encoder
with one method for each scalar kind. Containers and passthrough are left
out: a sealed field is one scalar, and the engine refuses anything else.

gensupport converts and checks the public types, and stashgen recognises
them by their name in encrypt only. stashgen stops refusing a vcvalue
type in an opaque struct; encrypt.UUID is its sixteen bytes there, as the
storage profile writes it.

Tests: frame's publish tests use types of their own for the value, the
envelope, the storage blob and the Encryptable paths, and the refusals.
encrypt's tests check each public type and each Encoder method writes the
codec's bytes and decodes back as itself. go generate leaves every
generated file as it was.
…guarded them

Nothing in the module imports vitaminc's vcffi or vcvalue any more, so
go.mod no longer requires them, and neither do the two nested modules
(encrypt/encrypttest, encrypt/example), which carried them as indirect
requirements. go mod tidy in each removes them and their go.sum lines, and
changes nothing else. The TEMPORARY comment that explained the pin goes
with it.

scripts/go-release-version.mjs refused a final version while go.mod
pinned a vitaminc module at a pseudo-version, because vitaminc's Go
bindings had no tags. The module now has no dependency that could carry
such a pin: the codec is in this repository, and vitaminc's Go bindings
are to be removed. The rule and its tests go. A test now checks that the
script reads the module path from the tree's go.mod and accepts a final
version from main.
The frame codec brought three fuzz targets with it: FuzzUnmarshal,
FuzzUnmarshalCipherText and FuzzUnmarshalStorage, in internal/frame. go
test replays their seeds on every pull request already, and go:fuzz finds
them on its own, but the nightly campaign runs one matrix row per target,
and crates-ci.test.mjs fails until every target has one.

They run no guest, so their rows name none, and the guest build step is
skipped for them. docs/fuzzing.md lists them, and the go:fuzz task's
description says it fuzzes the codec too.
…ange

The Go codec was vitaminc's vcffi, and the docs said so. Each now names
languages/golang/internal/frame instead:

- AGENTS.md lists frame among the module's internal packages, drops the
  release rule about a vitaminc pin, and says how the codec is fuzzed.
- STORAGE.md, the value corpus README and the exchange contract name the
  Go codec here as their Go reader. The corpus README no longer mentions
  a Go encryption guest or a differential run, which were vitaminc's.
- The encrypt and stashgen READMEs describe the value types and the
  storage blob without naming vitaminc's packages.
- go-binding-test.sh says which codec its 386 run protects.

languages/golang/CHANGELOG.md, Unreleased: encrypt.UUID, Encryptable and
Encoder under Added; the value types becoming types of their own under
Breaking, with what changes for code that named vcvalue or vcffi; and the
codec moving into the module under Changed.

The plan's stage 3 gets a Done list, with vitaminc's own cleanup and the
differential fuzzers left to do.
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI; Enforced overrides: Organization
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c5b6b6cb-a6f4-4a4b-9791-effcde316b60

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

@github-actions

Copy link
Copy Markdown
Contributor

Mutation testing (cargo-mutants, --in-diff, stack-auth, stack-encrypt, stack-encrypt-jsonpath, vitaminc-aead, recipher-frame, vitaminc-aead-derive)

No mutants were generated for the changed lines.

@coderdan coderdan left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review (/code-review medium) of 5b860a6. Four findings, all checked against the code: one important, below because its file is outside the diff, and three nits inline.

Important: .github/workflows/tests-golang.yml (outside the diff). A change to the value corpus does not run the Go tests that now read it. internal/frame/conformance_test.go and fuzz_test.go read conformance/vitaminc-aead/value-conformance.json, but neither the pull_request nor the push path filter lists conformance/vitaminc-aead/**. The filter lists packages/recipher-frame/** for the storage corpus, and conformance/stack-encrypt/**. Failure scenario: a pull request adds a value vector that the Go codec decodes differently. Only tests-crates.yml runs, it passes on the Rust side, and the Go drift reaches main with no red check.

I will fix all four in this pull request and reply here and on each thread.


// valueCorpus is the cross-language value corpus that Rust and Node read
// too. Its README says which sections each language checks.
const valueCorpus = "../../../../conformance/vitaminc-aead/value-conformance.json"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frame package's tests read corpora outside the Go module and fail when they are missing. ../../../../conformance/... and ../../../../packages/recipher-frame/testdata/storage-v1.json are not in the module zip. TestSharedValueConformance, the storage corpus tests (storage_test.go:42) and the fuzz seed loader (fuzz_test.go:26) call t.Fatal/f.Fatal when the file is absent.

Failure scenario: An application runs go test all with this module in its build list: internal/frame's tests fail with "no such file or directory".

Severity: nit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 23569b3. A new helper, internal/frame/corpus_test.go's readCorpus, reads both corpora. A missing corpus still fails inside this repository, detected by the .git at the repository root, or when STACK_CONFORMANCE_REQUIRED=1 is set. Anywhere else, the value and storage corpus tests skip. The fuzz targets still run from their committed testdata. A new test checks that both corpora are required inside the repository. I checked it with a copy of the module outside the repository: the tests skip and the package passes there, and with STACK_CONFORMANCE_REQUIRED=1 the same copy fails.

x := rv.Interface().(Uint128)
w.buf = append(append(w.buf, tagUint128), x[:]...)
return true, nil
case plainType, dateType, timestampType, decimalType, taggedType:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A refusal names the internal type, not the one the program used. model calls internalValue(rv) first and then reports "%s has no storage form", rv.Type(), so an encrypt.Decimal is reported as frame.Decimal, a package the program cannot import.

Failure scenario: A hand-built source holding an encrypt.Decimal goes to MarshalStorage; the error says frame.Decimal has no storage form.

Severity: nit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9be31bb. model keeps the type it was given and names that type in the "has no storage form" error. A new test in encrypt/values_test.go checks that encrypt.Decimal, and a struct holding an encrypt.Date, are refused with their own names and no frame. type. The test fails without the fix.

Comment thread languages/golang/encrypt/errors.go Outdated
// ErrStorageVersion is an opaque struct sealed as a storage blob of a
// version this release does not read: a later release wrote it. Its error
// wraps [ErrEncoding] too. It is vcffi.ErrUnsupportedVersion, named here so
// wraps [ErrEncoding] too. It is frame.ErrUnsupportedVersion, named here so

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc comments still describe the removed vitaminc dependency. ErrStorageVersion is named here "so a program can check for it without importing vitaminc's bindings"; gensupport/codec.go:382 says "vitaminc's storage profile". Rust docs also still say the Go SDK writes through vcffi.MarshalStorage or names vcvalue.TypedNull: stack-encrypt/src/blob.rs:102, stack-encrypt/Cargo.toml:72, stack-encrypt/tests/opaque_blob.rs:266, stack-encrypt/tests/value_bytes.rs:680, stack-guest-abi/src/value.rs:7, recipher-frame/tests/serde.rs:45.

Failure scenario: A reader follows a comment to vcffi or vcvalue.TypedNull, neither of which this module uses any more.

Severity: nit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b3981ee. These no longer name removed code:

  • Go: the ErrStorageVersion doc, the doc comments in gensupport/codec.go and declaration.go, and a test comment.
  • Rust: the blob.rs module doc, the stack-encrypt/Cargo.toml comment, the doc comments in tests/opaque_blob.rs and tests/value_bytes.rs (the vcvalue.TypedNull one), stack-guest-abi/src/value.rs, and recipher-frame/tests/serde.rs.
  • Also fixed: stack-guest-abi/src/buffers.rs pointed at vitaminc's vcencrypt guest. Several Cargo.toml comments said the guests live under bindings/go; they now say languages/golang.

ADRs, plans and changelogs keep their mentions, because they record history. For the Rust crates, fmt, clippy, rustdoc (public and private) and the touched tests pass.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor One more stale site: .github/workflows/release-golang.yml:32-34 still says a final version is refused "while go.mod pins vitaminc's Go bindings at a pseudo-version (scripts/go-release-version.mjs)", a rule this PR deletes. End the sentence at "a final version is cut from main only."

Source: code-review (medium) · claude-opus-5-5


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 95a739b. The sentence in release-golang.yml now ends at "a final version is cut from main only." No other description of the removed rule remains outside plans and changelogs.

internal/frame's conformance test and its fuzz seeds read
conformance/vitaminc-aead/value-conformance.json, so a change to that
corpus must run them. tests-golang.yml's pull_request and push filters
listed the storage corpus's crate and the stack-encrypt corpus, but not
this one.
internal/frame's tests read the value and storage corpora from the
repository, outside the Go module, so the module a program downloads does
not carry them, and its go test all failed on a missing file.

readCorpus now tells the two cases apart. In the repository, which it
finds by the .git four levels up, or with STACK_CONFORMANCE_REQUIRED=1, a
missing corpus still fails. Anywhere else a test skips, and a fuzz target
runs from its testdata alone. A test pins that the repository requires
both corpora.

Checked by copying the module out of the repository: the corpus tests
skip and the package passes, and with STACK_CONFORMANCE_REQUIRED=1 it
fails.
The storage writer reads a published type as the codec's value type, and
then named that type in its refusal, so an encrypt.Decimal in an opaque
struct was reported as frame.Decimal, a package the program cannot see.
The writer now keeps the type it was given for the message.

Tests: encrypt.Decimal and a struct holding an encrypt.Date are refused
with their own names and no frame type, and the frame test checks the
same for a published type of its own. The encrypt test fails without the
fix.
…meant

Comments and rustdoc still said the Go SDK writes the storage profile
"through vcffi.MarshalStorage", named vcvalue.TypedNull, or called the
profile and the leaf types "vitaminc's bindings". That code is gone: the
Go SDK's frame codec is languages/golang/internal/frame now, and a typed
null is what Go writes for a nil pointer to a fixed-width type.

- Go: encrypt.ErrStorageVersion's doc, two gensupport docs and a test
  comment.
- Rust: stack-encrypt's blob module doc, its Cargo.toml note and two test
  docs; stack-guest-abi's value and buffers module docs; recipher-frame's
  serde test. The buffers doc also pointed at vitaminc's vcencrypt guest.
- The guests' and stack-guest-abi's Cargo.toml comments said the guests
  live under bindings/go, the module's old path.

No code changes. ADRs, plans and changelogs keep their historical names.
@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a4d45c4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderdan

Copy link
Copy Markdown
Contributor Author

Review follow-up on the path filter, the finding outside the diff: fixed in 1ad6005. conformance/vitaminc-aead/** is now in both the pull_request and push path lists of .github/workflows/tests-golang.yml. No script test lists these paths. The workflow script tests pass: workflow-paths-filter-parity, tests-workflow-gate, stack-conformance-ci, crates-ci, go-nested-modules and go-release-version. The three inline findings are answered on their threads.

@coderdan
coderdan marked this pull request as ready for review November 27, 2026 14:43
@coderdan
coderdan requested a review from a team as a code owner November 27, 2026 14:43

@cipherstash-agent cipherstash-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review attestation

Reviewed b3981ee5 · posted from Claude Code (scheduled routine) · claude-opus-5-5 · effort medium
Sources: code-review (medium) · claude-opus-5-5; mattpocock-skills:code-review standards and spec axes · model not confirmed. Every finding was verified at b3981ee5 and cross-checked against the existing threads.
Skills: code-review, company-skills:rust-security, mattpocock-skills:code-review, company-skills:review-cross-check, company-skills:review-post

Findings (8): 8 minor — 6 inline, 1 below, 1 in reply.

  • general minor The PR body says "Closes #1253", but #1253 item 5 (port the differential fuzzers to languages/golang/encrypt/guest) is not done, and the plan's "Still to do" says so; no other issue tracks it. The base is next, so GitHub will not auto-close it, but closing it by hand on this PR's word leaves item 5 untracked. Use "Refs #1253" or move item 5 to its own issue.
    Source: mattpocock-skills:code-review spec axis · model not confirmed

company-skills:rust-security: the Rust changes are comments only; nothing in scope.

Checked and not posted (refuted at head): JSONOpen/NewJSONRead taking frame.Object (unreachable outside the module, since both also need an internal *record.Plan), the corpus skip inside the repository, the FixedWidth test name, the widen.go switches.

Open questions for the author, not defects:

  • A nil pointer to an Encryptable is now a 1-byte plain null where its value is 9 bytes, and the engine pads nothing on an Untyped field. Generated code cannot reach this, but a program that calls gensupport.Declare(...).Encrypt("v", gensupport.Untyped) itself can. Refuse a nil Encryptable where no type is declared?
  • The CHANGELOG says ParseInt128, ParseUint128, ParseDecimal and ErrNonFiniteDecimal are "unchanged", but their error text now starts frame: , naming an internal package. errors.Is still matches.
  • encrypt/query.go:122 tells callers to pass a frame.Object, a type outside the module cannot name.
  • The reflect-keyed registry in internal/frame/public.go versus Go principle #4 ("do not use reflection"), and the removal of Date.DaysFromCE/Decimal.Normalized: both already in the PR's own open questions.

Generated by Claude Code

Comment thread languages/golang/encrypt/encoder.go Outdated
}

// Encoder takes the one value an Encryptable writes. Only the Encoder handed
// to EncryptValue can be written to; the zero Encoder panics.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor A zero encrypt.Encoder panics on every method (var e encrypt.Encoder; e.Int64(1) dereferences a nil st), which contradicts encrypt/cipher.go:40 "no call on this package panics"; a user's unit test calling v.EncryptValue(encrypt.Encoder{}) hits it. Make each method a no-op that records an error when st == nil, or narrow the claim in cipher.go.

Source: mattpocock-skills:code-review standards axis · model not confirmed


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8d51ca9. Every encrypt.Encoder method now does nothing on the zero value instead of panicking. A new Encoder.Err() returns the first error of an encode, wrapped as ErrEncoding. On the zero value it says the Encoder keeps nothing. Tests cover each method on the zero value, and EncryptValue(encrypt.Encoder{}).

)

// publishable are the value types the SDK may publish a type of its own for.
var publishable = map[reflect.Type]bool{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor A type added to publishable but never passed to Publish raises nothing: the encrypt type is then written by reflection (a [16]byte as Bytes, a struct as a Map) and decodes as the frame type. Only the opposite mistake panics at init. Add a test that ranges over publishable and checks each entry is in publicOf.

Source: mattpocock-skills:code-review standards axis · model not confirmed


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8d51ca9. A new frame.Unpublished() lists any type that could be published but was not. A test in encrypt requires it to be empty after encrypt's init. Removing the UUID registration makes that test fail.


// implementsEncryptable reports whether t is an Encryptable or implements
// the published one.
func implementsEncryptable(t reflect.Type) bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor frame.Encryptable is implemented only by frame's own tests, so encryptableOf and implementsEncryptable check two interfaces where production needs one. Have the tests register their interface through PublishEncryptable and drop the internal one.

Source: mattpocock-skills:code-review standards axis · model not confirmed


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8d51ca9. frame.Encryptable is gone. The codec checks only the interface published through PublishEncryptable, and frame's own tests publish their test interface the same way.


// UInt32 records an unsigned 32-bit integer. For schema fidelity with the
// EQL layer.
func (e Encoder) UInt32(u uint32) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor frame spells UInt8…UInt128 (here and scalars.go:18-22) while encrypt.Encoder and frame.Uint128 (values.go:24) spell Uint. Rename to Uint* so the codec and SDK use one Go spelling.

Source: mattpocock-skills:code-review standards axis · model not confirmed


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8d51ca9. UInt8…UInt128 are now Uint8…Uint128 throughout frame and its callers.

// Encoder records a single value in transport form. It mirrors the Rust
// Cipher channels — it is a recorder that writes the transport bytes, not a
// live cipher handle. Exactly one channel must be used per Encoder: a
// terminal (Null, Undefined, Bool, Int32, Int64, UInt32, UInt64, Float32,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor The terminal list omits Int8, Int16, Int128, UInt8, UInt16, UInt128, Date, Timestamp, TimestampParts, Decimal, UUID and Tagged (scalars.go). List them or say "a scalar method (see scalars.go)".

Source: mattpocock-skills:code-review standards axis · model not confirmed


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8d51ca9. frame.Encoder's doc now names every kind of terminal method.

Comment thread mise.toml Outdated

[tasks."go:fuzz"]
description = "Fuzz the guests' ABI from Go: run every Fuzz* target in languages/golang for GO_FUZZTIME each (default 60s), or only the target GO_FUZZ names; needs `wasm:guest:build:deterministic` and `wasm:auth-guest:build` first"
description = "Fuzz the guests' ABI and the frame codec from Go: run every Fuzz* target in languages/golang for GO_FUZZTIME each (default 60s), or only the target GO_FUZZ names; needs `wasm:guest:build:deterministic` and `wasm:auth-guest:build` first"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor The frame targets need no guest: every package compiles without one, and go test ./internal/frame -fuzz '^FuzzUnmarshal$' passes with none built. Say the guest builds are needed only for the encrypt and auth targets. In fuzz.yml, if: matrix.guest != '' on the Swatinem/rust-cache step would stop the frame rows caching guest workspaces they never compile.

Source: code-review (medium) · claude-opus-5-5


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 95a739b. In fuzz.yml, if: matrix.guest != '' is now on the Swatinem/rust-cache step too; the guest build step already had it. The go:fuzz description in mise.toml says only the encrypt and auth targets need a guest.

@coderdan

Copy link
Copy Markdown
Contributor Author

On the review's general finding: the description now says "Refs #1253" rather than "Closes #1253". Item 5, porting the differential fuzzers to the Go guest, is tracked in #2004. The inline findings and the review's open questions are being fixed; I will reply on each thread.

Review fixes to the codec and the public Encoder:

- encrypt.Encoder's methods called on the zero Encoder panicked, though
  no call on the package should. A type's own unit test can call
  EncryptValue with encrypt.Encoder{}. Each method now does nothing on the
  zero Encoder, and the new Encoder.Err reports the encode's first error
  as ErrEncoding, or, on the zero Encoder, that it keeps nothing.
  frame.Encoder gains Usable and Err for it.
- frame.Unpublished lists a value type the codec can publish that nothing
  published. A type left out of encrypt's init would be written by
  reflection and decoded as frame's own type; encrypt's tests now fail
  if any is left out.
- frame had an Encryptable of its own beside the published one, used only
  by its tests, so the codec checked two interfaces where it needs one.
  It is gone; the tests publish theirs as encrypt does.
- frame spelled the unsigned methods UInt8 to UInt128, and encrypt and
  frame's own types spell them Uint. They are Uint8 to Uint128 now.
- frame.Encoder's doc lists every kind of terminal method.
ParseInt128, ParseUint128, ParseDecimal, ParseUUID and the types'
Validate returned the codec's errors, whose text starts "frame: ", the
name of a package a program cannot import. They now start "encrypt: ",
and errors.Is still finds the codec's error beneath.
ErrNonFiniteDecimal is this package's own value, which ParseDecimal
returns for NaN and the infinities. gensupport's refusal of an instant
outside the wire's range says "encrypt: invalid timestamp" for the same
reason.
The codec writes a nil pointer to an Encryptable as the one-byte null.
On a field that declares its type the engine pads a null to that type's
width, so nothing shows. On a field with no declared type nothing pads
it, and a value such as an int64 is nine bytes, so the stored length
would show which rows are null. vitaminc's FixedWidth, which let a type
name the width of its null, is gone.

Generated code always declares a type. A program that builds a plan or a
declaration with no type can reach this, so Cipher.Seal now refuses such
a value with ErrEncoding before anything is sent, naming the field. A
nil pointer to a built-in fixed-width type is still a typed null, and is
not refused. The test fails without the check, and checks that a typed
field seals a nil Encryptable as long as a value.
…ject

QueryTerm's doc told a caller to pass a frame.Object, a type of an
internal package. It now says what the input holds: the operator's
named inputs, in order, as generated code builds them.
…elease rule

The frame codec's fuzz rows already skipped the guest build, but still
restored and saved a Rust cache for the guests. That step is skipped for
them too now. The go:fuzz task's description says only the encrypt and
auth targets need a guest.

release-golang.yml's header still said a final version is refused while
go.mod pins vitaminc's Go bindings. The script no longer has that rule.
Encoder.Err and the zero Encoder under Added. Under Breaking, the parse
functions' errors now start "encrypt: ", and Seal refuses a nil
Encryptable on a field with no declared type.
@coderdan

Copy link
Copy Markdown
Contributor Author

On the review's open questions:

  • A nil Encryptable on a field with no declared type: refused now (311320f). Cipher.Seal refuses a nil pointer to an Encryptable, at any depth, on a field with no declared type. It returns ErrEncoding before anything is sent, so the stored length cannot show a null. The old padded null is not brought back: getting its width would mean calling a user's EncryptValue on a zero value, which can panic, and a type's output need not have a fixed width. On a typed field with sealed nulls, a nil Encryptable still seals to a value's length. The test fails without the check.
  • Error text naming frame: fixed (316207d). ParseInt128, ParseUint128, ParseDecimal, ParseUUID, Date.Validate and Decimal.Validate return errors starting "encrypt: ", and errors.Is still matches. ErrNonFiniteDecimal is now encrypt's own value. The CHANGELOG says what changed instead of "unchanged". Codec errors from encoding a value, such as invalid UTF-8, still read "frame: …" inside the wrapped ErrEncoding text.
  • encrypt/query.go:122: the doc now describes the input as generated code builds it, without naming frame.Object (061da75).

One thing beyond the doc: several exported encrypt.Cipher methods take types a program cannot import. These are QueryTerm, Verify, TargetLimit, Contexts, Seal, Open and JSONOpen, which take a *record.Plan, and JSONOpen, which also takes a frame.Object. They are documented as being for generated code, and the *record.Plan part was already true before this branch. The API is unchanged. This is added to the description's open questions.

The comments of internal/frame came from vitaminc with the code. Many
were long sentences with asides, arrows and terms a new reader has not
met. They now use short sentences, lists for parallel cases, and plain
words: "method" for a channel, "the encoded bytes" for the wire, "the
caller" for a binding.

The package comment defines a frame, the guest, a passthrough value and
a sealed leaf where it first uses them. The tag constants define a tag,
a typed null, an envelope and a physical scalar.

Every stated fact about the byte format is kept: the tag values, the
limits, the order of keys and what each decoder refuses. Test comments
no longer name the review or the fuzz run that found a case.

Four comments were wrong and are corrected. storage.go named the
vitaminc paths of the storage specification and corpus, not the paths
in this repository. Object's comment said the type is only decoded, but
Encode accepts one. Marshal's comment named a binding's Encrypt as its
caller. The package comment said that a value only goes into the Stack
Encrypt guest and a ciphertext only comes out. Both cross in both
directions, and the auth guest returns values too.

Only comments change.
These are the doc comments and code comments that the frame codec move
added or changed outside internal/frame: package encrypt's value types,
Encryptable and Encoder, QueryTerm's input, gensupport's conversions,
stashgen's storage rules, and the tests beside them.

The public docs now say what each type or function is for, what it
returns and what it refuses, in short sentences. QueryTerm lists the
input for each kind of operator, and the three cases that return
ErrEncoding. A paragraph that the move changed is rewritten whole, so
that it reads as one piece.

The comments on the two guests' stack-guest-abi dependency and on the
golangci exclusion for internal/frame are rewritten the same way.

Only comments change.
The Rust doc comments, Cargo.toml comments, workflow comments and the
comment in go-binding-test.sh that name the Go frame codec are rewritten
in short sentences, with no asides in brackets.

stack-guest-abi's module docs say that a HostValue implements the
Encrypt model of vitaminc-aead, and name where the Go module reads a
frame. release-golang.yml says where each kind of version can be
released from, in two sentences.

Only comments change.
…c move

The Go CHANGELOG entries for the value types, Encryptable and the
vitaminc dependency are rewritten for a developer who upgrades. The
Breaking entry now lists what stays the same, what changes for every
program, and what to change in code that names a vcvalue or vcffi type.
The Changed entry defines the frame codec and the storage profile.

docs/fuzzing.md lists the two rules that the frame fuzz targets check.
The plan's stage 3 Done list, STORAGE.md, the two READMEs, the
conformance docs and AGENTS.md get the same treatment for the passages
that the move changed. AGENTS.md describes internal/frame in sentences
of its own, not in an aside inside the list of packages.
A Go developer reads these messages when an encode, a decode, or a read
of a stored value fails. Several messages used the codec's own words, a
dash that joined two ideas, or an idiom. A reader had to know the code
to understand them.

Each message now says what was wrong and, where it is short, what to do:

- A struct with no exported fields names encrypt.Encryptable, the
  interface the developer implements, and says what implementing it
  does.
- A wrong number of values names EncryptValue, the method that wrote
  them, and says how many complete values it wrote.
- A text method that fails is named: MarshalText or UnmarshalText of
  the type.
- An integer that is too large for its Go type is "outside the range
  of" that type.
- A repeated key has the same words in the value encoding as in the
  storage profile.
- The zero Encoder has the same message in frame and in encrypt.
- A timestamp out of range no longer has two parts joined by a colon.

Six other messages change a few words each, such as "has" for "holds".

No behaviour changes. Each error is the same sentinel and wraps the same
errors. The codec returns each error for the same input. No message
contains a value.

No test changes. The tests check a few words of each message, and all of
those words are still in the messages.
The merge brings in the error message changes from next. Every guest
answer is now read through `internal/guest`. A decrypt error never names
the kind of the decrypted value. This branch moved the frame codec into
`internal/frame`, so the merged code uses frame types in place of vcffi
and vcvalue.

How each conflict was resolved:

- CHANGELOG.md: the Unreleased section keeps the entries from both
  sides. The Added, Breaking and Changed lists each contain both sets.
- auth/step.go, auth/store.go, encrypt/checker.go, json.go, query.go and
  records.go: the code from next is kept. That code reads each answer
  through guest.DecodeAnswer and guest.BadAnswer. The merged code uses
  frame.Object and frame.Field in place of the vcvalue types.
- encrypt/gensupport/convert.go: valuesOf from next is kept, with
  frame.Object. valuesOf takes the Go type that the field needs.
- encrypt/targets_test.go: the tests from next are kept, with frame
  types and frame.Marshal.

Files that merged cleanly but still named vitaminc:

- internal/guest/answer.go: DecodeAnswer calls frame.Unmarshal. KindOf
  switches on the frame value types. The cases for the sealed and typed
  null types of vcvalue are removed, because package frame has no such
  types. A typed null decodes as nil. KindOf names nil "null".
- internal/frame/public.go: new function Native. The decoders return the
  types that package encrypt publishes, such as encrypt.UUID. KindOf
  calls Native first, so that it names a UUID "a UUID" and not "bytes".
- internal/guest/answer_test.go and auth/answer_test.go: frame types in
  place of the vcvalue types.
- encrypt/values_test.go: a new test checks that KindOf names each type
  that package encrypt publishes by its kind.
Brings in #2011. Its changes to the Go guest are a new status code for a
refused single value. They do not touch the frame codec that this branch
moves into the module.

One conflict, in tests/value_bytes.rs. Both sides changed the doc
comment and the signature of typed_null_section. The merge keeps the doc
comment from this branch, because that comment no longer names vcvalue.
The merge keeps the signature from next. That signature takes the shared
Kept type for the keys.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants